package next.Functionality;


import android.content.Intent;
import android.net.Uri;
import android.util.Log;


public class EmailFunctionality extends SmsFunctionality {

	//--Variables--
	//--example: private String[] to = { "kiquened85@gmail.com", "ndiazgranados@nextlabteam.com" };
	
	/** Called when the User send a mail. */
	public void CreateEmail( String[] emailAddresses, String[] carbonCopies,String subject, String message) {

		//--Default Values
		if (emailAddresses==null || subject==null || message==null )
		{
			Log.d("Error sending mail", "Null parameter unaceptable");
			return;
		}	
		
		sendEmail( emailAddresses, carbonCopies,subject, message);
			
	}

	/**Sends an SMS message to another device/s*/
	private void sendEmail(String[] emailAddresses, String[] carbonCopies,	String subject, String message) {
		Intent emailIntent = new Intent(Intent.ACTION_SEND);
		emailIntent.setData(Uri.parse("mailto:"));
		String[] to = emailAddresses;
		String[] cc = carbonCopies;
		emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
		emailIntent.putExtra(Intent.EXTRA_CC, cc);
		emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
		emailIntent.putExtra(Intent.EXTRA_TEXT, message);
		emailIntent.setType("message/rfc822");
		startActivity(Intent.createChooser(emailIntent, "Email"));
	}
}